home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / initramfs-tools / examples / example_hook_cpiogz next >
Encoding:
Text File  |  2008-06-11  |  2.5 KB  |  85 lines

  1. #!/bin/sh
  2.  
  3. #
  4. # The environment contains at least:
  5. #
  6. #  CONFDIR -- usually /etc/mkinitramfs, can be set on mkinitramfs
  7. #         command line.
  8. #
  9. #  DESTDIR -- The staging directory where we are building the image.
  10. #
  11. # TODO: Decide what environment variables are meaningful and defined
  12. #    in this context, then document them as part of the interface.
  13. #
  14. # TODO: Write a common header for these examples or move this
  15. #    documentation to a man page and reference it here. :-)
  16. #
  17.  
  18. #
  19. # List the soft prerequisites here.  This is a space separated list of
  20. # names, of scripts that are in the same directory as this one, that
  21. # must be run before this one can be.
  22. #
  23. PREREQ=""
  24.  
  25. prereqs()
  26. {
  27.     echo "$PREREQ"
  28. }
  29.  
  30. case $1 in
  31. # get pre-requisites
  32. prereqs)
  33.     prereqs
  34.     exit 0
  35.     ;;
  36. esac
  37.  
  38. #
  39. # Source the 'hook-functions' scriptlet (for 'catenate_cpiogz'):
  40. #
  41. . /usr/share/initramfs-tools/hook-functions
  42.  
  43. #
  44. # Lets pretend it has a conffile (think debconf), and we source it
  45. # here.  Don't make debconf lookup calls here.  The postinst for the
  46. # package owning this hook script should have done that and configured
  47. # the "/etc/default/conffile" already.
  48. #
  49. # TODO: How does the package ensure that it's installed BEFORE the
  50. #    corresponding 'linux-image' package?  Can it declare that, in
  51. #    the case where it's an add-on that the 'linux-image' is not
  52. #    aware of?  This might be an apt and dpkg issue.
  53. #
  54. #    * Eg. an optional usplash or suspend2ui_fbsplash package.
  55. #
  56. . /etc/default/mypackage-initramfs
  57.  
  58. #
  59. # Also pretend that we only include our initramfs overlay if an opion
  60. # is not "no", and the 'linux-image' package we are generating this
  61. # initramfs for matches the version this script's package is designed
  62. # for.  Just for example; pretend this example mkinitramfs hook script
  63. # is part of a 'linux-image' or 'xxx-modules' package.
  64. #
  65. if [ "$MYOPTION" != "no" -a "$version" = "2.6.12+ss2.1.9.1" ]; then
  66.     catenate_cpiogz /usr/lib/mypackage/initramfs.cpio.gz
  67. fi
  68.  
  69. #
  70. # In this case, there does not have to be an (eg.):
  71. #
  72. #   "/etc/mkinitramfs/init-top/mypackage"
  73. #
  74. # ... since that script is probably inside of the initramfs overlay
  75. # already.  If it's a conffile though, it does not belong in there,
  76. # and should be placed in the appropriate location inside of
  77. # "/etc/mkinitramfs".  Remember that if it needs access to the
  78. # settings in our "/etc/default/mypackage-initramfs", then that file
  79. # must also get copied into a location inside of ${DESTDIR} by this
  80. # hook script in order to make it available inside of the initramfs
  81. # environment.
  82. #
  83.  
  84. exit 0
  85.